<?php
require_once 'Text/CAPTCHA.php';  

class captcha_process{

	private $path ;
	private $file_name ;
	private $options ;
	private $captcha ;

	function __construct( ){
		
		$this->path = "../../templates/picture/captcha/" ;
		$this->file_name = 'captcha.jpg' ;		
		$this->options = array('font_size'=>'30','font_file'=>'MONACO.TTF');

		$this->captcha = Text_CAPTCHA::factory('Image'); 
			
	}

	
	function set_path( $path ){
		
		$this->path = $path ;
	        return true ;	
	}
	function set_file_name( $file_name ){
		
		$this->file_name = $file_name ;
	        return true ;	
	}
	function get_path_and_file_name(){
		
		return 	$this->path.'/'.$this->file_name;
	}
	function set_option( $options ){			
		
		$this->options = $options ;
		return true ;
	}
	function create_img( $width = 120  , $height = 60 ){

		$this->captcha->init( $width , $height , NULL, $this->options );  
		$image = $this->captcha->getCAPTCHAAsJPEG();  
		
		$handle = fopen( $this->path.$this->file_name , 'w' );  
		fwrite($handle, $image);  
		fclose($handle);  
		
		return true ;

	}
	function get_phrase(){
		
		return $this->captcha->getPhrase();  
	}
	static function delete_img( $path_and_file_name ){
		
		return unlink( $path_and_file_name ) ;
	}

}
?>
